package com.trimps.wifi.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.trimps.wifi.mapper.AlarmMapper;
import com.trimps.wifi.pojo.Alarm;
import com.trimps.wifi.pojo.FlowData;
import com.trimps.wifi.service.IAlarmService;

@Service("alarmService")
public class AlarmServiceImpl implements IAlarmService {
	@Autowired
	private AlarmMapper alarmMapper;	

	@Override
	public int getAlarmCount(String keyword) {
		return alarmMapper.getAlarmCount(keyword);
	}

	@Override
	public List<Alarm> getAllAlarms(String keyword, int currentPage, int rowPerPage) {
	    int start = 0;
        if (rowPerPage == 0) {
            rowPerPage = 10;
        }
        if (currentPage != 0) {
            start = (currentPage - 1) * rowPerPage;
        }
		return  alarmMapper.getAllAlarms(keyword, start, rowPerPage);
	}
	
	@Override
    public List<Alarm> getAlarmListByKeyword(String keywords, String deviceNo,String startTime, String endTime) {
        return this.alarmMapper.getAlarmListByKeyword(keywords, deviceNo, startTime, endTime);
    }

    @Override
    public int getAlarmListCountByKeyword(String keywords, String deviceNo, String startTime, String endTime) {
        return this.alarmMapper.getAlarmListCountByKeyword(keywords, deviceNo, startTime, endTime);
    }

}
